package cn.ibobo.lease.admin.service.impl;

import cn.ibobo.lease.common.base.BaseMapper;
import cn.ibobo.lease.common.base.BaseServiceImpl;
import cn.ibobo.lease.admin.dao.UserOrderMapper;
import cn.ibobo.lease.admin.service.UserOrderService;
import cn.ibobo.lease.common.dto.UserOrderDTO;
import cn.ibobo.lease.common.util.UuidUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;
import java.util.List;


/**
 * 用户订单表业务处理接口
 * @Author lililiang
 * @Date 2018-12-22 14:49:46
 */
@Service
public class UserOrderServiceImpl extends BaseServiceImpl<UserOrderDTO, String> implements UserOrderService {

    private static final Log LOGGER = LogFactory.getLog(UserOrderServiceImpl.class);

    @Autowired
    private UserOrderMapper mapper;

    @Override
    protected BaseMapper<UserOrderDTO, String> getMapper() {
        return mapper;
    }

    /**
     * 用户订单表列表
     * @Author lililiang
     * @Date 2018-12-22 14:49:46
     * @Param
     * @Return
     */
    @Override
    public List<UserOrderDTO> list4Page(UserOrderDTO entity, Integer pageNum, Integer... pageSize) {
        return super.list4Page(entity, pageNum, pageSize);
    }

    /**
     * 用户订单表列表（无分页）
     * @Author lililiang
     * @Date 2018-12-22 14:49:46
     * @Param
     * @Return
     */
    @Override
    public List<UserOrderDTO> listByCondition(UserOrderDTO entity) {
        return super.listByCondition(entity);
    }

    /**
     * 查询用户订单表详情信息
     * @Author lililiang
     * @Date 2018-12-22 14:49:46
     * @Param
     * @Return
     */
    @Override
    public UserOrderDTO queryOneByPk(String id) {
        return super.queryOneByPk(id);
    }

    /**
     * 保存用户订单表信息
     * @Author lililiang
     * @Date 2018-12-22 14:49:46
     * @Param
     * @Return
     */
    @Override
    @Transactional
    public Integer save(UserOrderDTO entity) {
        String id = entity.getId();
        if(id == null){
            entity.setId(UuidUtil.getUuid());
            return mapper.add(entity);
        }else {
            return mapper.edit(entity);
        }
    }

    /**
     * 删除用户订单表信息
     * @Author lililiang
     * @Date 2018-12-22 14:49:46
     * @Param
     * @Return
     */
    @Override
    @Transactional
    public Integer delete(String id) {
        return super.delete(id);
    }
}
